<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// laravel5.4里面的路由 放置 routes/web.php 文件
Route::get('/', function () {
    return view('welcome');
});

//\Illuminate\Support\Facades\Auth::guard('backLogin')->loginUsingId(2); // 注意：Auth门面提供的了一个方法用来做用户登录的测试loginUsingId

Route::match(['GET', 'POST'], '/back/login', 'Admin\BackController@login')->name('login');// 1. 展示 2. 收集

Route::group(['middleware' => ['auth:backLogin', 'checkAuth']], function(){
    Route::get('/back/logout', 'Admin\BackController@logout');

    // 定义后台首页路由 首页 = index + welcome
    Route::get('/admin/index', 'Admin\IndexController@index');
    Route::get('/admin/welcome', 'Admin\IndexController@welcome');

    // 定义用户curd操作
    Route::get('/admin/user/lst', 'Admin\UserController@lst');
    // 定义datatable数据展示
    Route::get('/admin/user/dlst', 'Admin\UserController@dlst');
    Route::post('/admin/user/datatable', 'Admin\UserController@datatable');


    Route::post('/admin/user/del', 'Admin\UserController@del');
    // 编辑的路由 1.展示 2. 收集
    Route::match(['get', 'post'], '/admin/user/edt/{id}', 'Admin\UserController@edt');
    // 添加 1. 展示 2. 收集
    Route::match(['get', 'post'], '/admin/user/add', 'Admin\UserController@add');
    // 用户锁定 isLocked
    Route::post('/admin/user/isLocked', 'Admin\UserController@isLocked');

    // 定义权限操作 1. 展示 2. 添加
    Route::get('/admin/auth/lst', 'Admin\AuthController@lst');
    Route::match(['get', 'post'], '/admin/auth/add', 'Admin\AuthController@add');

    // 定义角色的 1. 展示 2. 添加
    Route::get('/admin/role/lst', 'Admin\RoleController@lst');
    Route::match(['get', 'post'], '/admin/role/add', 'Admin\RoleController@add');
    // 角色权限分配
    Route::match(['get', 'post'], '/admin/role/fenpei/{id}', 'Admin\RoleController@fenpei');

    // 会员的展示和添加
    Route::get('/admin/member/lst', 'Admin\MemberController@lst');
    Route::match(['get', 'post'], '/admin/member/add', 'Admin\MemberController@add');
    // 定义文件上传的url
    Route::post('/admin/upload/laravel', 'Admin\MemberController@laravel'); // laravel本地上传

    Route::post('/admin/upload/qiniu', 'Admin\MemberController@qiniu'); // 七牛云上传

    // 学科的展示和添加
    Route::get('/admin/subject/lst', 'Admin\SubjectController@lst');
    Route::match(['get', 'post'], '/admin/subject/add', 'Admin\SubjectController@add');

    // 专业展示
    Route::get('/admin/profession/lst', 'Admin\ProfessionController@lst');
    // 专业添加
    Route::match(['get', 'post'], '/admin/profession/add', 'Admin\ProfessionController@add');

    // 任课老师的选择
    Route::get('/admin/profession/teacher', 'Admin\ProfessionController@teacher');

    // 课程的展示和添加
    Route::get('/admin/course/lst', 'Admin\CourseController@lst');
    // 课程添加
    Route::match(['get', 'post'], '/admin/course/add', 'Admin\CourseController@add');

    // 课时的展示和添加
    Route::get('/admin/lession/lst', 'Admin\LessionController@lst');
    // 课时添加
    Route::match(['get', 'post'], '/admin/lession/add', 'Admin\LessionController@add');
    // 课时的播放 /admin/lession/show/
    Route::get('/admin/lession/show/{id}', 'Admin\LessionController@show');

});


// 测试拼音类
Route::get('/py', function(){
    $pinyin = app('pinyin');
    echo $pinyin->permalink('带着希望去旅行，比到达终点更美好','_');

});